package Demo.菜鸟驿站;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Expressage extends JFrame {
    private JTextField txtInput;
    private JButton Confirm;
    private JPanel p1,p2;
    private JLabel catalogue,catalogue1,catalogue2,catalogue3;




    public Expressage(){
        this.setTitle("菜鸟驿站");
        this.setBounds(400,100,400,200);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        txtInput = new JTextField(20);
        p1 =new JPanel();
        Confirm = new JButton("确认");
        p1.add(txtInput, BorderLayout.WEST);
        p1.add(Confirm,BorderLayout.EAST);
        this.add(p1, BorderLayout.SOUTH);
        p2 = new JPanel();
        p2.setLayout(new GridLayout(4,1,5,5));
        catalogue =new JLabel("欢迎使用菜鸟驿站");
        catalogue1 =new JLabel("请输入选项：");
        catalogue2 = new JLabel("1.登陆系统");
        catalogue3 = new JLabel("2.退出系统");
        p2.add(catalogue);
        p2.add(catalogue1);
        p2.add(catalogue2);
        p2.add(catalogue3);
        this.add(p2,BorderLayout.NORTH);

        Confirm.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
            int a = Integer.parseInt(txtInput.getText());
            if (a==2){
                System.exit(0);
            }else if (a==1){
                Register g = new Register();
                g.Register();
                //自动关闭

                Expressage.this.dispose();

            }else if(txtInput.getText().equals("")){
                JOptionPane.showMessageDialog(null,"请输入内容");
            }
            else{
                JOptionPane.showMessageDialog(null,"错误");
            }
            }
        });
    }

    public static void main(String[] args) {
        Expressage expressage = new Expressage();
        expressage.setVisible(true);
    }
}
